package online.afeibaili.storebackendframework

import online.afeibaili.storebackendframework.model.json.CouponJsonMapper
import online.afeibaili.storebackendframework.other.OrderInterfaceImpl
import online.afeibaili.storebackendframework.service.impl.AccountServiceImpl
import online.afeibaili.storebackendframework.service.impl.OrderServiceImpl
import online.afeibaili.storebackendframework.service.impl.ProductServiceImpl
import online.afeibaili.storebackendframework.service.impl.ShoppingCartServiceImpl
import online.afeibaili.storebackendframework.util.OrderGenerator
import online.afeibaili.storebackendframework.util.RuntimeTimeUtil
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class StoreBackendFrameworkApplicationTests {
    @Autowired
    lateinit var orderInterfaceImpl: OrderInterfaceImpl

    @Autowired
    lateinit var accountService: AccountServiceImpl

    @Autowired
    lateinit var productService: ProductServiceImpl

    @Autowired
    lateinit var orderServiceImpl: OrderServiceImpl

    @Autowired
    lateinit var shoppingCartServiceImpl: ShoppingCartServiceImpl

    @Autowired
    lateinit var generator: OrderGenerator

    @Test
    fun loadData() {
//        generator.generateProducts(100)
//        generator.generateOrderCart("1", 99)
    }

    @Test
    fun contextLoads() {
        RuntimeTimeUtil {
            println(productService.getById(1763117818209))
        }.printTime()
    }

    @Test
    fun couponTest() {
        accountService.addCoupons(
            "oYcFA1z2sBEpxu1-Q78s1z4Pugwo", listOf(
                CouponJsonMapper(1763191963265, System.currentTimeMillis(), 1)
            )
        )
    }

    @Test
    fun saveProduct() {
        /*        flowerDirectory.listFiles().forEach {
                    val details: ProductDetails = readProductDirectory(it)
                    productService.create(
                        ProductEntity(
                            details.title,
                            details.price.toDouble(),
                            details.images.joinToString(","),
                            "",
                            "",
                            ProductEntity.DetailJsonMapper.toJson(
                                ProductEntity.DetailJsonMapper(
                                    details.materials,
                                    details.flowerSay,
                                    details.normalPrice,
                                    details.tag
                                )
                            ),
                            "",
                            "",
                            "",
                            0
                        )
                    )
                }*/
    }
}
